<template>
	<div>
		<el-dialog :title="$t('action.update')" width="70%" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
			<el-form :size="size" ref="form" :model="form" :rules="rules" :label-width="$store.getters.device !== 'mobile'?'16%':'90px'">
 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_ReceiveBillNo')" prop="ReceiveBillNo">
							<el-input v-model="form.ReceiveBillNo" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_ReceiveBillNo')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_SourceQty')" prop="SourceQty">
							<el-input v-model="form.SourceQty" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_SourceQty')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_AbnormalQty')" prop="AbnormalQty">
							<el-input v-model="form.AbnormalQty" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_AbnormalQty')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_PurBillNo')" prop="PurBillNo">
							<el-input v-model="form.PurBillNo" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_PurBillNo')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_MaterialNumber')" prop="MaterialNumber">
							<el-input v-model="form.MaterialNumber" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_MaterialNumber')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_MaterialName')" prop="MaterialName">
							<el-input v-model="form.MaterialName" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_MaterialName')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_UnitNumber')" prop="UnitNumber">
							<el-input v-model="form.UnitNumber" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_UnitNumber')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_UnitName')" prop="UnitName">
							<el-input v-model="form.UnitName" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_UnitName')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Abnormal_Date')" prop="Date">
							<el-input v-model="form.Date" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Abnormal_Date')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
				</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button :size="size" :loading="loading" type="primary" @click="submit" >
					<span v-if="!loading">{{$t('system.confirm')}}</span>
					<span v-else>{{$t('system.submitting')}}</span>
				</el-button>
				<el-button :size="size" @click="closeForm">{{$t('system.cancel')}}</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
import { update } from '@/api/app/abnormal'

export default {
	name:'abnormalupdate',
	components: {
	},
	props: {
		show: {
			type: Boolean,
			default: false
		},
		size: {
			type: String,
			default: 'small'
		},
		info: {
			type: Object,
		},
	},
	data(){
		return {
		    dialog:{
			},
			form: {
			   ReceiveBillNo:'',
			   SourceQty:'',
			   AbnormalQty:'',
			   PurBillNo:'',
			   MaterialNumber:'',
			   MaterialName:'',
			   UnitNumber:'',
			   UnitName:'',
			   Date:'',
			},
		    initial:{},        
			loading:false,
			rules: {
			}
		}
	},
	watch:{
		show(val){
			if(val){
			}
		}
	},
	methods: {
		open(){
			this.form = this.info
		},
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					update(this.form).then(res => {
						if(res.status == 200){
							this.$message({message: this.$t('system.success'), type: 'success'})
							this.$emit('refresh_list')
							this.closeForm()
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
		closeForm(){
			this.$emit('update:show', false)
			this.loading = false
			if (this.$refs['form']!==undefined) {
				this.$refs['form'].resetFields()
			}
		},
	}
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss'
</style>
